package jianzhi

import "sort"

func findRepeatNumber(nums []int) int {
	sort.Ints(nums)

	for i := 0; i < len(nums)-1; i++ {
		if nums[i] == nums[i+1] {
			return nums[i]
		}
	}

	return -1
}

func findRepeatNumber2(nums []int) int {
	numsMap := make(map[int]int)

	for _, v := range nums {
		if _, ok := numsMap[v]; ok {
			return v
		} else {
			nums[v] = 1
		}
	}

	return -1
}
